package com.example.medmobile;

import WebService.SoapWebService;
import android.app.ProgressDialog;
import android.content.Context;
import android.os.Handler;

import com.google.appengine.medmobileserver.business.Paciente;

public class ListaAgendamentoHandler extends ListaAgendamento implements
		Runnable {

	private Context context;

	@Override
	protected void CarregaLista(final Context context) {
		try {
			String s = "";
			this.context = context;

				dialog = ProgressDialog.show(context, "Carregando",
						"Por favor aguarde.", true, false);
			new Thread(ListaAgendamentoHandler.this).start();

		} catch (Exception e) {
			e.getMessage();
		}
	}

	@Override
	public void run() {

		Paciente p = Global.getPacienteLogado();

		li = SoapWebService.BuscaAgendamentoPaciente(p.getIdPaciente());
		runOnUiThread(new Runnable() {
			public void run() {
				try {
					ListaAgendamentoAdapter ra = new ListaAgendamentoAdapter(
							context, li);

					listView.setAdapter(ra);

				} finally {
					dialog.dismiss();
				}

			}
		});
	}

}
